{extend name="common/base" /}
{block name="title"}{$info.name}下载 - WampServer中文站{/block}
{block name="head"}
{if $info.remark != ''}<meta name="description" content="{:mb_substr($info['remark'], 0, 255)}">{/if}
<style>
    .list-group-item {
        text-decoration: none!important;
    }
</style>
{/block}
{block name="body"}
<div class="container" style="margin-top: 65px;">
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{:url('Index/index')}">首页</a></li>
            <li class="breadcrumb-item">软件</li>
            <li class="breadcrumb-item">{$info.category.title}</li>
            <li class="breadcrumb-item active" aria-current="page">软件详情</li>
        </ol>
    </nav>
    <div class="row">
        <div class="col-sm-12 col-md-8">
            <div class="card">
                <h5 class="card-header">{$info.name}</h5>
                <table class="table table-borderless">
                    <tbody>
                    <tr><th>版本</th><td>{$info.version}</td><th>位数</th><td>{$info.bit_text}</td></tr>
                    <tr><th>大小</th><td>{$info.size_text}</td><th>下载次数</th><td>{$info.download_count}</td></tr>
                    <tr><th>发布时间</th><td>{$info.release_date}</td><th>入库时间</th><td>{:substr($info.create_time, 0, -9)}</td></tr>
                    <tr>
                        <th>MD5</th>
                        <td colspan="3">
                            {$info.md5}
                            <button type="button" class="btn btn-secondary btn-sm" data-bs-toggle="modal" data-bs-target="#hash-help-modal"><i class="bi bi-terminal"></i></button>
                        </td>
                    </tr>
                    <tr>
                        <th>在线查毒</th>
                        <td colspan="3">
                            <a href="https://www.virustotal.com/gui/search/{$info.md5}" target="_blank">VirusTotal</a>
                            <a href="https://www.virscan.org/report/{$info.md5}" target="_blank">VirSCAN</a>
                            <a href="https://habo.qq.com/file/showdetail?md5={$info.md5}" target="_blank">腾讯哈勃</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="card mt-3">
                <h5 class="card-header">
                    软件介绍
                </h5>
                <article class="card-body">
                    {:nl2br($info.remark)}
                </article>
            </div>
            <div class="card mt-3">
                <h5 class="card-header">下载地址</h5>
                <div class="card-body" id="mirror-list">
                </div>
                <div class="card-footer small">如果以上的下载点都无法下载，请尝试更换浏览器（本站没有对IE浏览器进行详细的兼容测试）</div>
            </div>
        </div>
        <div class="col-sm-12 col-md-4">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <h5 class="card-header">相关文章</h5>
                        <div class="list-group list-group-flush">
                            {foreach $info->article as $res}
                            <a class="list-group-item" href="{:url('Article/info', ['id' => $res['id']])}">{$res.title}</a>
                            {/foreach}
                        </div>
                    </div>
                </div>
                <div class="col-12 mt-3">
                    <ins class="adsbygoogle"
                         style="display:block"
                         data-ad-client="ca-pub-8372518057241672"
                         data-ad-slot="5304974058"
                         data-ad-format="auto"
                         data-full-width-responsive="true"></ins>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="hash-help-modal" tabindex="-1" aria-labelledby="hash-help-modal-label" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="hash-help-modal-label">哈希值计算</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <p>Windows 7 系统开始，系统自带签名命令，我们可以利用该工具进行哈希值计算。对比下载文件的哈希值和网站上给出哈希值是否一致，如果不一致，下载的文件可能被篡改，是病毒文件。</p>
          <p>我们可以打开终端(CMD)，输入 <code>certutil.exe -hashfile '<b>文件路径</b>' MD5</code> 来计算本地文件的哈希值。</p>
          <p>如果是PowerShell，还支持使用 <code>Get-FileHash -Algorithm MD5 '<b>文件路径</b>'</code> 命令来计算本地文件的哈希值。</p>
        </div>
      </div>
    </div>
  </div>
{/block}
{block name="script"}
<script src="/public/static/js/jquery-qrcode.js"></script>
<script>
    $(document).ready(function () {
        // 获取下载点
        $.get("{:url('Software/mirror', ['id' => $Request.param.id], false)}", function (result) {
            let html = '';
            result.data.forEach(function (mirror) {
                let badge = '';
                $.each(mirror.badge, function (name, className) {
                    badge += `<span class="ms-1 badge ${className}">${name}</span>`;
                });
                if (badge === '') {
                    html += `
                    <a href="${mirror.url}" class="btn btn-outline-secondary mirror-item" data-name="${mirror.name}" data-needpay="${mirror.need_pay}">
                        ${mirror.title}
                    </a>`;
                } else {
                    html += `
                    <a href="${mirror.url}" class="btn btn-outline-primary mirror-item" data-name="${mirror.name}" data-needpay="${mirror.need_pay}">
                        ${mirror.title}${badge}
                    </a>`;
                }
            });
            $('#mirror-list').html(html);
        });
    });
</script>
{/block}